<?php
// +----------------------------------------------------------------------
// | Tplay [ WE ONLY DO WHAT IS NECESSARY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://tplay.pengyichen.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 听雨 < 389625819@qq.com >
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\controller\Permissions;
use \think\Db;
class Config extends Permissions
{
    #系统配置管理
    public function index()
    {
        $web_config = Db::name('config')->where('id',1)->find();
        if ($this->request->isPost()) {
            $param = $this->request->post();
            if ( Db::name('config')->where('id',1)->update([$param['name']=>$param['value']]) ) {
                return json(['code'=>1,'msg'=>'ok']);
            }
                return json(['code'=>-1,'msg'=>'no']);

        }else{
            $data = [];
            $data[0] = ['withdrawals_little_money',$web_config['withdrawals_little_money'],'提现最小金额']; 
            // $data[1] = ['generation',$web_config['generation'],'直推多少个有效会员 拿几代静态分红奖']; 
            $data[1] = ['percentage_little',$web_config['percentage_little'],'分红拿代数的百分比(%) -- 2 4 6 8 10 12代']; 
            $data[2] = ['percentage_big',$web_config['percentage_big'],'分红拿代数的百分比(%) -- 1  3  5 7 9 11 代']; 
            // $data[3] = ['algebra',$web_config['algebra'],'直推多少个有效会员 拿 奖']; 
            $data[3] = ['procedures',$web_config['procedures'],'提现手续费']; 
            $data[4] = ['account_little_money',$web_config['account_little_money'],'转账最小金额']; 
            $data[5] = ['pool_to_momey',$web_config['pool_to_momey'],'矿池转出比例']; 
            $this->assign('web_config',$data);
            return $this->fetch();
        }
    }
}
